<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 创建事件监听
    document.body.addEventListener("myEvent", function () {
      this.style.background = "aqua";
    });
    // 创建myEvent事件示例
    var event = new Event("myEvent");
    // 触发事件
    document.body.dispatchEvent(event);
  </script>
</html>
